function [PQ, status, scheduledTargets] = BsMf_Schedule(PQ, sensor1TargetOrder, sensor2TargetOrder, param)
%BsMf_Schedule Summary of this function goes here
%   Detailed explanation goes here

% Initialise variables
s1rows = size(sensor1TargetOrder, 1);
s1cols = size(sensor1TargetOrder, 2);
s2rows = size(sensor2TargetOrder, 1);
s2cols = size(sensor2TargetOrder, 2);

scheduledTargets = [];
status = 0;

maxPriority = param.schedule.max_priority;

if isempty(PQ)
  PQ = PQ_Init(maxPriority);
end

if (s1rows == 0) || (s1cols == 0) || (s2rows == 0) || (s2cols == 0)
  % error in inputs, nothing to do.
  return;
end

% Work out all Bi-static/Measurement-Fusion tasks
[PQ] = SS_AddEqualTasks(PQ, sensor1TargetOrder, sensor2TargetOrder, maxPriority);

% Remove all missing target tasks
[PQ] = SS_PruneMissingTasks(PQ, sensor1TargetOrder, sensor2TargetOrder);

% Schedule the sensors
if strcmp(param.schedule.algorithm, 'IA')
  [PQ, status, scheduledTargets] = BsMf_Schedule_IntervalAlgebra(PQ, sensor1TargetOrder, sensor2TargetOrder, param);
elseif strcmp(param.schedule.algorithm, 'IH')
  [PQ, status, scheduledTargets] = BsMf_Schedule_IntervalAlgebra_Hogge(PQ, sensor1TargetOrder, sensor2TargetOrder, param);
elseif strcmp(param.schedule.algorithm, 'IG')
  [PQ, status, scheduledTargets] = BsMf_Schedule_IntervalAlgebra_Grow(PQ, sensor1TargetOrder, sensor2TargetOrder, param);
elseif strcmp(param.schedule.algorithm, 'IS')
  [PQ, status, scheduledTargets] = BsMf_Schedule_IntervalAlgebra_SCP(PQ, sensor1TargetOrder, sensor2TargetOrder, param);
elseif strcmp(param.schedule.algorithm, 'IM')
  [PQ, status, scheduledTargets] = BsMf_Schedule_IntervalAlgebra_SCP_Matrix(PQ, sensor1TargetOrder, sensor2TargetOrder, param);
elseif strcmp(param.schedule.algorithm, 'IP')
  [PQ, status, scheduledTargets] = BsMf_Schedule_IntervalAlgebra_SCP_Parallel(PQ, sensor1TargetOrder, sensor2TargetOrder, param);
elseif strcmp(param.schedule.algorithm, 'GS')
  [PQ, status, scheduledTargets] = BsMf_Schedule_GRASP(PQ, sensor1TargetOrder, sensor2TargetOrder, param);
elseif strcmp(param.schedule.algorithm, 'G2')
  [PQ, status, scheduledTargets] = BsMf_Schedule_GRASP2(PQ, sensor1TargetOrder, sensor2TargetOrder, param);
elseif strcmp(param.schedule.algorithm, 'SC')
  [PQ, status, scheduledTargets] = BsMf_Schedule_SCP(PQ, sensor1TargetOrder, sensor2TargetOrder, param);
elseif strcmp(param.schedule.algorithm, 'SA')
  [PQ, status, scheduledTargets] = BsMf_Schedule_SCP_All(PQ, sensor1TargetOrder, sensor2TargetOrder, param);
elseif strcmp(param.schedule.algorithm, 'SG')
  [PQ, status, scheduledTargets] = BsMf_Schedule_SCP_GRASP(PQ, sensor1TargetOrder, sensor2TargetOrder, param);
elseif strcmp(param.schedule.algorithm, 'HA')
  [PQ, status, scheduledTargets] = BsMf_Schedule_Heuristic_Ambiguous(PQ, sensor1TargetOrder, sensor2TargetOrder, param);
else %if strcmp(param.schedule.algorithm, 'HR')
  [PQ, status, scheduledTargets] = BsMf_Schedule_Heuristic(PQ, sensor1TargetOrder, sensor2TargetOrder, param);
end

% Cleanup work list
[PQ] = SS_UpdateTaskPriorities(PQ, scheduledTargets, param.schedule.max_scans);
scheduledTargets = scheduledTargets';
end